{
 "nbformat": 4,
 "nbformat_minor": 0,
 "metadata": {
  "colab": {
   "provenance": [],
   "machine_shape": "hm",
   "gpuType": "T4"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  },
  "language_info": {
   "name": "python"
  },
  "accelerator": "GPU"
 },
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/component_examples/named_entity_recognition_NER/NLU_explain_clinical_doc_vop_pipeline.ipynb)\n",
    "\n",
    "#Explain Clinical Document - Oncology - Pipeline\n",
    "\n",
    "This specialized oncology pipeline can;\n",
    "\n",
    "- extract oncological entities,\n",
    "\n",
    "- assign assertion status to the extracted entities,\n",
    "\n",
    "- establish relations between the extracted entities from the clinical documents."
   ],
   "metadata": {
    "id": "z4u-tnoeuTw_"
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "BH0D2XoiuSwN"
   },
   "outputs": [],
   "source": [
    "! pip install nlu pyspark==3.1.2"
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "! pip install johnsnowlabs"
   ],
   "metadata": {
    "id": "cgKcjsgOueXr"
   },
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "import json, os\n",
    "from google.colab import files\n",
    "\n",
    "if 'spark_jsl.json' not in os.listdir():\n",
    "  license_keys = files.upload()\n",
    "  os.rename(list(license_keys.keys())[0], 'spark_jsl.json')\n",
    "\n",
    "with open('spark_jsl.json') as f:\n",
    "    license_keys = json.load(f)\n",
    "\n",
    "# Defining license key-value pairs as local variables\n",
    "locals().update(license_keys)\n",
    "os.environ.update(license_keys)"
   ],
   "metadata": {
    "id": "7hklxZt9upoF"
   },
   "execution_count": 1,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "# Installing pyspark and spark-nlp\n",
    "! pip install --upgrade -q pyspark==3.1.2 spark-nlp==$PUBLIC_VERSION\n",
    "\n",
    "# Installing NLU\n",
    "! pip install --upgrade --q nlu --no-dependencies\n",
    "\n",
    "# Installing Spark NLP Healthcare\n",
    "! pip install --upgrade -q spark-nlp-jsl==$JSL_VERSION  --extra-index-url https://pypi.johnsnowlabs.com/$SECRET\n",
    "\n",
    "# Installing Spark NLP Display Library for visualization\n",
    "! pip install -q spark-nlp-display"
   ],
   "metadata": {
    "id": "ANul1bNvu7k4"
   },
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "import json\n",
    "import os\n",
    "\n",
    "import sparknlp\n",
    "import sparknlp_jsl\n",
    "import nlu\n",
    "\n",
    "from sparknlp.base import *\n",
    "from sparknlp.annotator import *\n",
    "from sparknlp_jsl.annotator import *\n",
    "\n",
    "from pyspark.sql import SparkSession\n",
    "from pyspark.sql import functions as F\n",
    "from pyspark.ml import Pipeline,PipelineModel\n",
    "\n",
    "import pandas as pd\n",
    "pd.set_option('display.max_colwidth', 200)\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "params = {\"spark.driver.memory\":\"16G\",\n",
    "          \"spark.kryoserializer.buffer.max\":\"2000M\",\n",
    "          \"spark.driver.maxResultSize\":\"2000M\"}\n",
    "\n",
    "print(\"Spark NLP Version :\", sparknlp.version())\n",
    "print(\"Spark NLP_JSL Version :\", sparknlp_jsl.version())\n",
    "\n",
    "spark = sparknlp_jsl.start(license_keys['SECRET'],params=params)\n",
    "\n",
    "spark"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 257
    },
    "id": "JjGxXc8Hu-R-",
    "outputId": "2a789444-a664-4adb-c907-fcbda9d2e644"
   },
   "execution_count": 2,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Spark NLP Version : 5.3.0\n",
      "Spark NLP_JSL Version : 5.3.0\n"
     ]
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<pyspark.sql.session.SparkSession at 0x7a4afcd961d0>"
      ],
      "text/html": [
       "\n",
       "            <div>\n",
       "                <p><b>SparkSession - in-memory</b></p>\n",
       "                \n",
       "        <div>\n",
       "            <p><b>SparkContext</b></p>\n",
       "\n",
       "            <p><a href=\"http://fbd24589d778:4040\">Spark UI</a></p>\n",
       "\n",
       "            <dl>\n",
       "              <dt>Version</dt>\n",
       "                <dd><code>v3.1.2</code></dd>\n",
       "              <dt>Master</dt>\n",
       "                <dd><code>local[*]</code></dd>\n",
       "              <dt>AppName</dt>\n",
       "                <dd><code>Spark NLP Licensed</code></dd>\n",
       "            </dl>\n",
       "        </div>\n",
       "        \n",
       "            </div>\n",
       "        "
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "model = nlp.load(\"en.explain_doc.clinical_oncology.pipeline\")"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "PnPestabv8m3",
    "outputId": "4f3e4591-978c-4ce9-966f-fc83f813950a"
   },
   "execution_count": 3,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "explain_clinical_doc_oncology download started this may take some time.\n",
      "Approx size to download 1.8 GB\n",
      "[OK!]\n"
     ]
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "text = [\"\"\"The Patient underwent a computed tomography (CT) scan of the abdomen and pelvis, which showed a complex ovarian mass. A Pap smear performed one month later was positive for atypical glandular cells suspicious for adenocarcinoma. The pathologic specimen showed extension of the tumor throughout the fallopian tubes, appendix, omentum, and 5 out of 5 enlarged lymph nodes. The final pathologic diagnosis of the tumor was stage IIIC papillary serous ovarian adenocarcinoma. Two months later, the patient was diagnosed with lung metastases.\"\"\"]"
   ],
   "metadata": {
    "id": "ZFPDQYF-wllN"
   },
   "execution_count": 4,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "df = model.predict(text)"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "OUlKhOtk2EBo",
    "outputId": "59c769a4-b029-43c3-fa17-2390a59ffdad"
   },
   "execution_count": 5,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "df"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 477
    },
    "id": "YGNdXIVU2GGv",
    "outputId": "31219544-135a-474e-fbd3-0cb25c70f0e9"
   },
   "execution_count": 6,
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "  all_relations_result  \\\n",
       "0                    O   \n",
       "\n",
       "                                                                                                    assertion  \\\n",
       "0  [Past, Past, Present, Past, Present, Possible, Past, Present, Present, Present, Present, Present, Present]   \n",
       "\n",
       "                                                                                      assertion_confidence  \\\n",
       "0  [0.9998, 0.9997, 0.9995, 0.9988, 0.957, 0.9251, 0.9993, 0.9978, 0.9992, 0.9787, 0.9994, 0.9962, 0.9975]   \n",
       "\n",
       "                                                                                                                                                                                                  document  \\\n",
       "0  The Patient underwent a computed tomography (CT) scan of the abdomen and pelvis, which showed a complex ovarian mass. A Pap smear performed one month later was positive for atypical glandular cell...   \n",
       "\n",
       "                                                                     entities_ner_jsl_chunk  \\\n",
       "0  [adenocarcinoma, tumor, tumor, papillary serous ovarian adenocarcinoma, lung metastases]   \n",
       "\n",
       "                                        entities_ner_jsl_chunk_class  \\\n",
       "0  [Oncological, Oncological, Oncological, Oncological, Oncological]   \n",
       "\n",
       "               entities_ner_jsl_chunk_confidence  \\\n",
       "0  [0.9974, 0.8333, 0.9892, 0.60825, 0.96220005]   \n",
       "\n",
       "  entities_ner_jsl_chunk_origin_chunk entities_ner_jsl_chunk_origin_sentence  \\\n",
       "0                     [0, 1, 2, 3, 4]                        [1, 2, 3, 3, 4]   \n",
       "\n",
       "                        entities_ner_oncology_anatomy_general_chunk  ...  \\\n",
       "0  [ovarian, fallopian tubes, appendix, omentum, lymph nodes, lung]  ...   \n",
       "\n",
       "                                                                                   relation_re_oncology_granular_wip_entity1_class  \\\n",
       "0  [Site_Other_Body_Part, Site_Other_Body_Part, Site_Other_Body_Part, Pathology_Test, Tumor_Finding, Tumor_Finding, Tumor_Finding]   \n",
       "\n",
       "  relation_re_oncology_granular_wip_entity1_end  \\\n",
       "0             [67, 78, 110, 128, 281, 281, 281]   \n",
       "\n",
       "                                relation_re_oncology_granular_wip_entity2  \\\n",
       "0  [mass, mass, mass, adenocarcinoma, fallopian tubes, appendix, omentum]   \n",
       "\n",
       "  relation_re_oncology_granular_wip_entity2_begin  \\\n",
       "0             [112, 112, 112, 213, 298, 315, 325]   \n",
       "\n",
       "                                                                              relation_re_oncology_granular_wip_entity2_class  \\\n",
       "0  [Tumor_Finding, Tumor_Finding, Tumor_Finding, Cancer_Dx, Site_Other_Body_Part, Site_Other_Body_Part, Site_Other_Body_Part]   \n",
       "\n",
       "  relation_re_oncology_granular_wip_entity2_end  \\\n",
       "0           [115, 115, 115, 226, 312, 322, 331]   \n",
       "\n",
       "  relation_re_oncology_granular_wip_origin_sentence  \\\n",
       "0                             [0, 0, 0, 1, 2, 2, 2]   \n",
       "\n",
       "                                                                                                                                                                                               sentence_dl  \\\n",
       "0  [The Patient underwent a computed tomography (CT) scan of the abdomen and pelvis, which showed a complex ovarian mass., A Pap smear performed one month later was positive for atypical glandular ce...   \n",
       "\n",
       "                                                                                                                                                                                      unlabeled_dependency  \\\n",
       "0  [underwent, underwent, ROOT, tomography, tomography, underwent, CT, tomography, CT, tomography, abdomen, abdomen, scan, pelvis, abdomen, abdomen, showed, abdomen, mass, mass, mass, showed, underwe...   \n",
       "\n",
       "                                                                                                                                                                                 word_embedding_embeddings  \n",
       "0  [[-0.0823686420917511, -0.3178570866584778, 0.07588467001914978, -0.5767543911933899, -0.5021305084228516, -0.27459028363227844, -0.22776539623737335, 0.2133890837430954, 0.03893626481294632, -0.0...  \n",
       "\n",
       "[1 rows x 44 columns]"
      ],
      "text/html": [
       "\n",
       "  <div id=\"df-86d4a192-5561-4509-ab40-9f888bd1dd5a\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>all_relations_result</th>\n",
       "      <th>assertion</th>\n",
       "      <th>assertion_confidence</th>\n",
       "      <th>document</th>\n",
       "      <th>entities_ner_jsl_chunk</th>\n",
       "      <th>entities_ner_jsl_chunk_class</th>\n",
       "      <th>entities_ner_jsl_chunk_confidence</th>\n",
       "      <th>entities_ner_jsl_chunk_origin_chunk</th>\n",
       "      <th>entities_ner_jsl_chunk_origin_sentence</th>\n",
       "      <th>entities_ner_oncology_anatomy_general_chunk</th>\n",
       "      <th>...</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity1_class</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity1_end</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity2</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity2_begin</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity2_class</th>\n",
       "      <th>relation_re_oncology_granular_wip_entity2_end</th>\n",
       "      <th>relation_re_oncology_granular_wip_origin_sentence</th>\n",
       "      <th>sentence_dl</th>\n",
       "      <th>unlabeled_dependency</th>\n",
       "      <th>word_embedding_embeddings</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>O</td>\n",
       "      <td>[Past, Past, Present, Past, Present, Possible, Past, Present, Present, Present, Present, Present, Present]</td>\n",
       "      <td>[0.9998, 0.9997, 0.9995, 0.9988, 0.957, 0.9251, 0.9993, 0.9978, 0.9992, 0.9787, 0.9994, 0.9962, 0.9975]</td>\n",
       "      <td>The Patient underwent a computed tomography (CT) scan of the abdomen and pelvis, which showed a complex ovarian mass. A Pap smear performed one month later was positive for atypical glandular cell...</td>\n",
       "      <td>[adenocarcinoma, tumor, tumor, papillary serous ovarian adenocarcinoma, lung metastases]</td>\n",
       "      <td>[Oncological, Oncological, Oncological, Oncological, Oncological]</td>\n",
       "      <td>[0.9974, 0.8333, 0.9892, 0.60825, 0.96220005]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[1, 2, 3, 3, 4]</td>\n",
       "      <td>[ovarian, fallopian tubes, appendix, omentum, lymph nodes, lung]</td>\n",
       "      <td>...</td>\n",
       "      <td>[Site_Other_Body_Part, Site_Other_Body_Part, Site_Other_Body_Part, Pathology_Test, Tumor_Finding, Tumor_Finding, Tumor_Finding]</td>\n",
       "      <td>[67, 78, 110, 128, 281, 281, 281]</td>\n",
       "      <td>[mass, mass, mass, adenocarcinoma, fallopian tubes, appendix, omentum]</td>\n",
       "      <td>[112, 112, 112, 213, 298, 315, 325]</td>\n",
       "      <td>[Tumor_Finding, Tumor_Finding, Tumor_Finding, Cancer_Dx, Site_Other_Body_Part, Site_Other_Body_Part, Site_Other_Body_Part]</td>\n",
       "      <td>[115, 115, 115, 226, 312, 322, 331]</td>\n",
       "      <td>[0, 0, 0, 1, 2, 2, 2]</td>\n",
       "      <td>[The Patient underwent a computed tomography (CT) scan of the abdomen and pelvis, which showed a complex ovarian mass., A Pap smear performed one month later was positive for atypical glandular ce...</td>\n",
       "      <td>[underwent, underwent, ROOT, tomography, tomography, underwent, CT, tomography, CT, tomography, abdomen, abdomen, scan, pelvis, abdomen, abdomen, showed, abdomen, mass, mass, mass, showed, underwe...</td>\n",
       "      <td>[[-0.0823686420917511, -0.3178570866584778, 0.07588467001914978, -0.5767543911933899, -0.5021305084228516, -0.27459028363227844, -0.22776539623737335, 0.2133890837430954, 0.03893626481294632, -0.0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 44 columns</p>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-86d4a192-5561-4509-ab40-9f888bd1dd5a')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-86d4a192-5561-4509-ab40-9f888bd1dd5a button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-86d4a192-5561-4509-ab40-9f888bd1dd5a');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "  <div id=\"id_e4f21fc3-ffcd-4af7-8253-c899d444dc5e\">\n",
       "    <style>\n",
       "      .colab-df-generate {\n",
       "        background-color: #E8F0FE;\n",
       "        border: none;\n",
       "        border-radius: 50%;\n",
       "        cursor: pointer;\n",
       "        display: none;\n",
       "        fill: #1967D2;\n",
       "        height: 32px;\n",
       "        padding: 0 0 0 0;\n",
       "        width: 32px;\n",
       "      }\n",
       "\n",
       "      .colab-df-generate:hover {\n",
       "        background-color: #E2EBFA;\n",
       "        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "        fill: #174EA6;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate {\n",
       "        background-color: #3B4455;\n",
       "        fill: #D2E3FC;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate:hover {\n",
       "        background-color: #434B5C;\n",
       "        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "        fill: #FFFFFF;\n",
       "      }\n",
       "    </style>\n",
       "    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('df')\"\n",
       "            title=\"Generate code using this dataframe.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "       width=\"24px\">\n",
       "    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "    <script>\n",
       "      (() => {\n",
       "      const buttonEl =\n",
       "        document.querySelector('#id_e4f21fc3-ffcd-4af7-8253-c899d444dc5e button.colab-df-generate');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      buttonEl.onclick = () => {\n",
       "        google.colab.notebook.generateWithVariable('df');\n",
       "      }\n",
       "      })();\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "application/vnd.google.colaboratory.intrinsic+json": {
       "type": "dataframe",
       "variable_name": "df"
      }
     },
     "metadata": {},
     "execution_count": 6
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "df[[\"entities_ner_jsl_chunk\", \"entities_ner_jsl_chunk_class\", \"assertion\"]]"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 98
    },
    "id": "cDWZ5mf52MDf",
    "outputId": "9302cee9-bba4-42a6-dcdd-24cf3812f373"
   },
   "execution_count": 8,
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "                                                                     entities_ner_jsl_chunk  \\\n",
       "0  [adenocarcinoma, tumor, tumor, papillary serous ovarian adenocarcinoma, lung metastases]   \n",
       "\n",
       "                                        entities_ner_jsl_chunk_class  \\\n",
       "0  [Oncological, Oncological, Oncological, Oncological, Oncological]   \n",
       "\n",
       "                                                                                                    assertion  \n",
       "0  [Past, Past, Present, Past, Present, Possible, Past, Present, Present, Present, Present, Present, Present]  "
      ],
      "text/html": [
       "\n",
       "  <div id=\"df-ae372e7c-08d5-479f-9b1c-9d68b874dfc6\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_ner_jsl_chunk</th>\n",
       "      <th>entities_ner_jsl_chunk_class</th>\n",
       "      <th>assertion</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[adenocarcinoma, tumor, tumor, papillary serous ovarian adenocarcinoma, lung metastases]</td>\n",
       "      <td>[Oncological, Oncological, Oncological, Oncological, Oncological]</td>\n",
       "      <td>[Past, Past, Present, Past, Present, Possible, Past, Present, Present, Present, Present, Present, Present]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-ae372e7c-08d5-479f-9b1c-9d68b874dfc6')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-ae372e7c-08d5-479f-9b1c-9d68b874dfc6 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-ae372e7c-08d5-479f-9b1c-9d68b874dfc6');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "application/vnd.google.colaboratory.intrinsic+json": {
       "type": "dataframe",
       "summary": "{\n  \"name\": \"df[[\\\"entities_ner_jsl_chunk\\\", \\\"entities_ner_jsl_chunk_class\\\", \\\"assertion\\\"]]\",\n  \"rows\": 1,\n  \"fields\": [\n    {\n      \"column\": \"entities_ner_jsl_chunk\",\n      \"properties\": {\n        \"dtype\": \"object\",\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"entities_ner_jsl_chunk_class\",\n      \"properties\": {\n        \"dtype\": \"object\",\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"assertion\",\n      \"properties\": {\n        \"dtype\": \"object\",\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}"
      }
     },
     "metadata": {},
     "execution_count": 8
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [],
   "metadata": {
    "id": "LiLX8Zqw6YfU"
   },
   "execution_count": null,
   "outputs": []
  }
 ]
}
